﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HalconDotNet;

using System.IO;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.ComponentModel;
using System.Windows.Forms;

namespace ImageDefine
{
   
    [Serializable]
    public class ImageToolBase
    {

       public string imageTaskName;
       public string strToolTypeName;
       public string strName;
       public string strRemark;    
       public bool   bResultOK;
       public string strMessage;
       public double dTimeUsed;
       public double dResultX;
       public double dResultY;
       public double dResultA;
       public double dResultScore;
       public bool bJudgeItem;

       
       [NonSerialized]
        public string strTaskName;
       [NonSerialized]
       public Dictionary<string, string> OutPutResults;
        [NonSerialized]
        public ImageTask imageTask;
        [NonSerialized]
        public List<ImageToolResult> ImageToolResults;
        public ImageToolBase()
       {
            imageTaskName="";
            strToolTypeName="";
            strName="";
            dResultX=0.0;
            dResultY=0.0;
            dResultA=0.0;
            bResultOK = false;
            strMessage = "";
            strRemark = "";
            bJudgeItem = false;
       }
        public ImageToolBase(ImageToolBase imageBase)
        {
            imageTaskName = imageBase.imageTaskName;
            strToolTypeName = imageBase.strToolTypeName;
            strName = imageBase.strName; ;
            dResultX = 0.0;
            dResultY = 0.0;
            dResultA = 0.0;
            bResultOK = false;
            strMessage = "";
            strRemark = imageBase.strRemark;
            bJudgeItem = imageBase.bJudgeItem;
        }
       virtual public void CreateActioner(ImageTask imageTaskIn)
       {
           OutPutResults = new Dictionary<string, string>();
           strTaskName = imageTask.Name;
            imageTask = imageTaskIn;
       }
        virtual public void Run(HalconDotNet.HImage hImage,SmartDisplayControl.SmartDisplayControl smartDisplay)
        {
            
        }
       virtual public string GetDecription()
       {
           return "最基本工具";
       }
        virtual public void ModifyName()
        {
            
        }
        virtual public ImageToolBase Copy()
        {

            ImageToolBase newImageTool = new ImageToolBase(this);
            return newImageTool;
        }
        virtual public ImageToolBase  Paste(ImageToolBase newTool)
        {

            return this;
        }
        [ReadOnly(true)]
        public string Name
        {
            get { return strName;}
            set {strName = value;}
        }
        public string Remark
        {
            get { return strRemark; }
            set { strRemark = value; }
        }
        [ReadOnly(true)]
        public bool ResultOK
        {
            get { return bResultOK; }
            set { bResultOK = value; }
        }
        [ReadOnly(true)]
        public string Message
        {
            get { return strMessage; }
            set { strMessage = value; }
        }
        [ReadOnly(true)]
        public double TimeUsed
        {
            get { return dTimeUsed; }
            set { dTimeUsed = value; }
        }
        [ReadOnly(true)]
        public double ResultX
        {
            get { return dResultX; }
            set { dResultX = value; }
        }
        [ReadOnly(true)]
        public double ResultY
        {
            get { return dResultY; }
            set { dResultY = value; }
        }
        [ReadOnly(true)]
        public double ResultA
        {
            get { return dResultA; }
            set { dResultA = value; }
        }
        public bool JudgeItem
        {
            get { return bJudgeItem; }
            set { bJudgeItem = value; }
        }
        [ReadOnly(true)]
        public string ToolTypeName
        {
            get { return strToolTypeName; }
            set { strToolTypeName = value; }
        }
        public virtual Form ShowSettingFrm()
        {
            return null;
        }
    }
}
